/**
 *
 */


Jx.declare('Jx.data.Index', {

	$actions: [

		'add',

		'update',

		'remove'

	],

	field: undefined,

	fieldName: undefined,

	table: undefined,

	records: undefined,

	constructor: function(table, field){

		this.table = table;

		this.field = field;

		this.name = field.name();

		this.records = {};

		this.values = {};

		this.$super();

	},

	onAfterAdd: function(operation, record){

		this.records[record.objectId] = true;

	},

	onAfterRemove: function(operation, record){

		delete this.records[record.objectId];

	},

	allowAdd: function(operation, record){

		return this.isIndexable(record);

	},

	allowRemove: function(operation, record){

		return this.isIndexed(record);

	},

	isIndexable: function(record){

		return this.isRecord(record) &&

			record.fields.get( this.name ) == this.field &&

			!this.records.hasOwnProperty( record.objectId );

	},

	isRecord: function(record){

		return Jx.instanceOf(record, this.table.model);

	},

	isIndexed: function(record){

		return this.isRecord(record) &&

			this.records.hasOwnProperty( record.objectId );

	},

	isMatched: function(value, record){

		return record.compare(value) == 0;

	},

	findRecordByValue: function(value){



	}




});
